package ooday04;

public class ooday05zy {
    public static void main(String[] args) {
        /*
        Master master = new Master();
        Dog dog = new Dog("小黑",2,"黑");
        Fish fish = new Fish("小金",1,"金");
        Chick chick = new Chick("大花",3,"花");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);

 */



        Animal[] animals = new Animal[6];
        animals[0] = new Dog("小黑", 2, "黑");
        animals[1] = new Dog("小白", 2, "白");
        animals[2] = new Dog("小灰", 2, "灰");
        animals[3] = new Fish("小金", 2, "金");
        animals[4] = new Fish("小黄", 2, "黄");
        animals[5] = new Chick("大花", 1, "花");
        for (int i=0;i<animals.length;i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if (animals[i] instanceof Chick){
                Chick chick = (Chick)animals[i];
                chick.layEggs();
            }
            if (animals[i] instanceof Dog){
                Dog dog= (Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Fish){
                Fish s= (Fish) animals[i];
                s.swim();
            }
        }


        


/*
        Master master = new Master();
        Dog dog = new Dog("小黑",2,"黑");
        Fish fish = new Fish("小金",1,"金");
        Chick chick = new Chick("大花",3,"花");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);





        Animal[] animals = new Animal[6];
        animals[0] = new Dog("小黑", 2, "黑");
        animals[1] = new Dog("小白", 2, "白");
        animals[2] = new Dog("小灰", 2, "灰");
        animals[3] = new Fish("小金", 2, "金");
        animals[4] = new Fish("小黄", 2, "黄");
        animals[5] = new Chick("大花", 1, "花");
        for (int i=0;i<animals.length;i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if (animals[i] instanceof Chick){
                Chick chick = (Chick)animals[i];
                chick.layEggs();
            }
            if (animals[i] instanceof Dog){
                Dog dog= (Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Fish){
                Fish s= (Fish) animals[i];
                s.swim();
            }
        }


         */
    }
}
